package com.example.customer;

import com.example.customer.CustomerRegistryRequest;
import com.example.customer.CustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/api/v1/customers")
@Slf4j
public record CustomerController(CustomerService customerService) {

    @GetMapping("/health")
    public String health() {
        return "customer service is running";
    }

    @PostMapping
    public void registerCustomer(
            @Valid @RequestBody CustomerRegistryRequest request) {
        log.info("new customer registration {}", request);
        customerService.registerCustomer(request);
    }
}